package com.java.demo;

import com.java.demo.controller.UserController;
import com.java.demo.controller.UserController2;
import com.java.demo.controller.UserController3;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: WHY
 * Date: 2023-07-22
 * Time: 13:17
 */
public class APP {
    public static void main(String[] args) {
        //这个静态方法是在Spring执行之前,所以拿不到注入对象,此时我们采取普通形式
        ApplicationContext context=new
                ClassPathXmlApplicationContext("spring-config.xml");
        //UserController userController=context.getBean("userController",UserController.class);
        //System.out.println(userController.getUser());
        UserController2 userController2=
                context.getBean("userController2",UserController2.class);
       userController2.sayHi();

        UserController3 userController3=
                context.getBean("userController3",UserController3.class);
               userController3.sayhi();
    }
}
